package com.xjtu.mybatisplus.web.controller.login;

//import com.xjtu.mybatisplus.common.Result;
import com.xjtu.mybatisplus.common.JsonResponse;
import com.xjtu.mybatisplus.model.dto.AuthUserDto;
import com.xjtu.mybatisplus.model.dto.ForgetDto;
import com.xjtu.mybatisplus.service.AuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * api登录授权
 *
 * @author zhuhuix
 * @date 2020-03-30
 */
@Slf4j
@RestController
@RequestMapping("api/auth")
@Api(tags = "系统授权接口")
public class AuthController {

    private final AuthService authService;

    public AuthController(AuthService authService) {
        this.authService = authService;
    }

    @ApiOperation("发送邮箱验证码")
    @PostMapping(value = "/getEmailCode")
    public JsonResponse getEmailCode(@RequestParam String email, @RequestParam String type) {

        return authService.sendMailCode(email,type);
    }

    @ApiOperation("注册")
    @PostMapping(value = "/register")
    public JsonResponse register(@RequestBody AuthUserDto authUserDto) {
        return authService.register(authUserDto);
    }


    @PostMapping("forget")
    @ApiOperation("忘记密码")
    public JsonResponse register(@RequestBody ForgetDto forgetDto){
        return authService.forget(forgetDto);
    }

}

